package nxu.it.movieapi.service.pg;

import nxu.it.api.model.Genre;
import nxu.it.api.service.GenreService;
import nxu.it.movieapi.service.pg.dao.GenreDao;
import nxu.it.movieapi.service.pg.entity.GenreEntity;
import nxu.it.movieapi.service.pg.mapper.GenreMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class GenreServicePgImpl implements GenreService {
    @Autowired
    GenreDao genreDao;
    @Autowired
    GenreMapper genreMapper;

    @Override
    public List<Genre> findAll() {
        List<GenreEntity> genreEntityList=genreDao.findAll();
        return genreMapper.fromEntityList(genreEntityList);
    }

    @Override
    public List<Genre> findByMovieId(Integer movieId) {
        List<GenreEntity> genreEntityList=genreDao.findByMovieId(movieId);
        return genreMapper.fromEntityList(genreEntityList);
    }

    @Override
    public List<Genre> findByName(String genreName) {
        List<GenreEntity> genreEntityList=genreDao.findByName(genreName);
        return genreMapper.fromEntityList(genreEntityList);
    }
}
